/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * WadsConfigDialog.java
 *
 * Created on Nov 29, 2009, 10:53:35 PM
 */

package sandbox;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import wads.app.WADDiagramEditor;
import wads.com.WADTools;

/**
 *
 * @author ManowTangdud
 */
public class WadsConfigDialog extends javax.swing.JDialog {

    /** Creates new form WadsConfigDialog */
    public WadsConfigDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        initCustoms();
    }

    public WadsConfigDialog(WADDiagramEditor parent, boolean modal) {
        super(parent, modal);
        initComponents();
        initCustoms();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        connectiontypeButtonGroup = new javax.swing.ButtonGroup();
        webserverPanel = new javax.swing.JPanel();
        webserverTextField = new javax.swing.JTextField();
        webserverCheckBox = new javax.swing.JCheckBox();
        webserverLabel = new javax.swing.JLabel();
        servletactionPanel = new javax.swing.JPanel();
        servletCheckBox = new javax.swing.JCheckBox();
        servletTextField = new javax.swing.JTextField();
        serveltLabel = new javax.swing.JLabel();
        dbserverPanel = new javax.swing.JPanel();
        dburlLabel = new javax.swing.JLabel();
        dbserverurlTextField = new javax.swing.JTextField();
        dbusernameLabel = new javax.swing.JLabel();
        dbusernameTextField = new javax.swing.JTextField();
        dbserverpwLabel = new javax.swing.JLabel();
        dbpwPasswordField = new javax.swing.JPasswordField();
        connectiontypeLabel = new javax.swing.JLabel();
        localhostRadioButton = new javax.swing.JRadioButton();
        embeddedRadioButton = new javax.swing.JRadioButton();
        internetRadioButton = new javax.swing.JRadioButton();
        rememberpwCheckbox = new javax.swing.JCheckBox();
        testconnectButton = new javax.swing.JButton();
        applyButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        okButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Configuration");
        setModal(true);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        webserverPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Web Server"));

        webserverTextField.setEnabled(false);

        webserverCheckBox.setText("Change server URL");
        webserverCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                webserverCheckBoxActionPerformed(evt);
            }
        });

        webserverLabel.setText("URL");

        javax.swing.GroupLayout webserverPanelLayout = new javax.swing.GroupLayout(webserverPanel);
        webserverPanel.setLayout(webserverPanelLayout);
        webserverPanelLayout.setHorizontalGroup(
            webserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(webserverPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(webserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(webserverLabel)
                    .addComponent(webserverCheckBox)
                    .addComponent(webserverTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 313, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(127, Short.MAX_VALUE))
        );
        webserverPanelLayout.setVerticalGroup(
            webserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(webserverPanelLayout.createSequentialGroup()
                .addComponent(webserverLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(webserverTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(webserverCheckBox)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        servletactionPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Servlet Action"));

        servletCheckBox.setText("Set servlet action URL");
        servletCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                servletCheckBoxActionPerformed(evt);
            }
        });

        servletTextField.setEnabled(false);

        serveltLabel.setText("Reference path");

        javax.swing.GroupLayout servletactionPanelLayout = new javax.swing.GroupLayout(servletactionPanel);
        servletactionPanel.setLayout(servletactionPanelLayout);
        servletactionPanelLayout.setHorizontalGroup(
            servletactionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(servletactionPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(servletactionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(servletTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 313, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(servletCheckBox)
                    .addComponent(serveltLabel))
                .addContainerGap(127, Short.MAX_VALUE))
        );
        servletactionPanelLayout.setVerticalGroup(
            servletactionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(servletactionPanelLayout.createSequentialGroup()
                .addComponent(serveltLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(servletTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(servletCheckBox)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        dbserverPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Database Server"));

        dburlLabel.setText("URL");

        dbusernameLabel.setText("Username");

        dbserverpwLabel.setText("Password");

        connectiontypeLabel.setText("Connection type");

        localhostRadioButton.setText("localhost");
        localhostRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                localhostRadioButtonActionPerformed(evt);
            }
        });

        embeddedRadioButton.setText("Embedded");
        embeddedRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                embeddedRadioButtonActionPerformed(evt);
            }
        });

        internetRadioButton.setSelected(true);
        internetRadioButton.setText("Internet");
        internetRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                internetRadioButtonActionPerformed(evt);
            }
        });

        rememberpwCheckbox.setSelected(true);
        rememberpwCheckbox.setText("Remember password?");

        testconnectButton.setText("Test Connection");

        javax.swing.GroupLayout dbserverPanelLayout = new javax.swing.GroupLayout(dbserverPanel);
        dbserverPanel.setLayout(dbserverPanelLayout);
        dbserverPanelLayout.setHorizontalGroup(
            dbserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dbserverPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dbserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dbserverPanelLayout.createSequentialGroup()
                        .addComponent(rememberpwCheckbox)
                        .addContainerGap())
                    .addGroup(dbserverPanelLayout.createSequentialGroup()
                        .addGroup(dbserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(dburlLabel)
                            .addComponent(dbserverurlTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 313, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(dbserverPanelLayout.createSequentialGroup()
                                .addGroup(dbserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(dbusernameLabel)
                                    .addComponent(dbusernameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(dbserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(dbpwPasswordField, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                                    .addComponent(dbserverpwLabel))))
                        .addGap(127, 127, 127))
                    .addGroup(dbserverPanelLayout.createSequentialGroup()
                        .addComponent(connectiontypeLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(localhostRadioButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(embeddedRadioButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(internetRadioButton)
                        .addContainerGap(144, Short.MAX_VALUE))
                    .addGroup(dbserverPanelLayout.createSequentialGroup()
                        .addComponent(testconnectButton)
                        .addContainerGap(329, Short.MAX_VALUE))))
        );
        dbserverPanelLayout.setVerticalGroup(
            dbserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dbserverPanelLayout.createSequentialGroup()
                .addComponent(dburlLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dbserverurlTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(dbserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dbusernameLabel)
                    .addComponent(dbserverpwLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(dbserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dbusernameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dbpwPasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rememberpwCheckbox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(testconnectButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
                .addGroup(dbserverPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(connectiontypeLabel)
                    .addComponent(localhostRadioButton)
                    .addComponent(embeddedRadioButton)
                    .addComponent(internetRadioButton))
                .addContainerGap())
        );

        applyButton.setText("Apply");
        applyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                applyButtonActionPerformed(evt);
            }
        });

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        okButton.setText("OK");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(dbserverPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(servletactionPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(webserverPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(okButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cancelButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(applyButton)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(webserverPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(servletactionPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(dbserverPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(applyButton)
                    .addComponent(cancelButton)
                    .addComponent(okButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void webserverCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webserverCheckBoxActionPerformed
        if(webserverCheckBox.isSelected())
            webserverTextField.setEnabled(true);
        else
            webserverTextField.setEnabled(false);
    }//GEN-LAST:event_webserverCheckBoxActionPerformed

    private void servletCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_servletCheckBoxActionPerformed
        if(servletCheckBox.isSelected())
            servletTextField.setEnabled(true);
        else
            servletTextField.setEnabled(false);
    }//GEN-LAST:event_servletCheckBoxActionPerformed

    private void localhostRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_localhostRadioButtonActionPerformed
        dbType = 1;
        dbusernameTextField.setText(configProps.getProperty(WadsConfigDialog.LOCAL_DB_USERNAME_KEY, ""));
        dbpwPasswordField.setText(configProps.getProperty(WadsConfigDialog.LOCAL_DB_PASSWORD_KEY, ""));
    }//GEN-LAST:event_localhostRadioButtonActionPerformed

    private void embeddedRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_embeddedRadioButtonActionPerformed
        dbType = 2;
        dbusernameTextField.setText(configProps.getProperty(WadsConfigDialog.LOCAL_DB_USERNAME_KEY, ""));
        dbpwPasswordField.setText(configProps.getProperty(WadsConfigDialog.LOCAL_DB_PASSWORD_KEY, ""));
    }//GEN-LAST:event_embeddedRadioButtonActionPerformed

    private void internetRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_internetRadioButtonActionPerformed
        dbType = 3;
        dbusernameTextField.setText(configProps.getProperty(WadsConfigDialog.LOCAL_DB_USERNAME_KEY, ""));
        dbpwPasswordField.setText(configProps.getProperty(WadsConfigDialog.LOCAL_DB_PASSWORD_KEY, ""));
    }//GEN-LAST:event_internetRadioButtonActionPerformed

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        saveConfig();
        this.dispose();
    }//GEN-LAST:event_okButtonActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        this.dispose();
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void applyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed
        saveConfig();
    }//GEN-LAST:event_applyButtonActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        this.dispose();
    }//GEN-LAST:event_formWindowClosing

    /**
    * @param args the command line arguments
    *
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                WadsConfigDialog dialog = new WadsConfigDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    */

    private void initCustoms() {
        connectiontypeButtonGroup.add(localhostRadioButton);
        connectiontypeButtonGroup.add(embeddedRadioButton);
        connectiontypeButtonGroup.add(internetRadioButton);

        loadConfig();
    }

    private void loadConfig() {
        try {
            configProps.load(new FileInputStream(configFile));
            server_url = configProps.getProperty(WadsConfigDialog.WEB_SERVER_URL_KEY, "");
            servlet_url = configProps.getProperty(WadsConfigDialog.SERVLET_ACTION_URL_KEY, "");

            if(configProps.getProperty(WadsConfigDialog.CURRENT_DB_TYPE_KEY).equals("localhost")) {
                dbserver_url = configProps.getProperty(WadsConfigDialog.LOCAL_DB_URL_KEY, "");
                dbusernameTextField.setText(configProps.getProperty(WadsConfigDialog.LOCAL_DB_USERNAME_KEY, ""));
                dbType = 1;
            }
            else if(configProps.getProperty(WadsConfigDialog.CURRENT_DB_TYPE_KEY).equals("embedded")) {
                dbserver_url = configProps.getProperty(WadsConfigDialog.EMBEDDED_DB_URL_KEY, "");
                dbusernameTextField.setText(configProps.getProperty(WadsConfigDialog.EMBEDDED_DB_USERNAME_KEY, ""));
                dbType = 2;
            }
            else if(configProps.getProperty(WadsConfigDialog.CURRENT_DB_TYPE_KEY).equals("internet")) {
                dbserver_url = configProps.getProperty(WadsConfigDialog.INTERNET_DB_URL_KEY, "");
                dbusernameTextField.setText(configProps.getProperty(WadsConfigDialog.INTERNET_DB_USERNAME_KEY, ""));
                dbType = 3;
            }
            else {
                dbserver_url = "";
                dbusernameTextField.setText("");
                dbType = 0;
            }

            if(configProps.getProperty(WadsConfigDialog.REMEMBER_PASSWORD_KEY).equals("yes")) {
                rememberpwCheckbox.setSelected(true);

                if(dbType==1) {
                    dbpwPasswordField.setText(configProps.getProperty(WadsConfigDialog.LOCAL_DB_PASSWORD_KEY, ""));
                }
                else if(dbType==2) {
                    dbpwPasswordField.setText(configProps.getProperty(WadsConfigDialog.EMBEDDED_DB_PASSWORD_KEY, ""));
                }
                else if(dbType==3) {
                    dbpwPasswordField.setText(configProps.getProperty(WadsConfigDialog.INTERNET_DB_PASSWORD_KEY, ""));
                }
                else {
                    dbpwPasswordField.setText("");
                }
            }
            else {
                rememberpwCheckbox.setSelected(false);
                dbpwPasswordField.setText("");
            }
            
            //load propeties to TextFields
            webserverTextField.setText(server_url);
            servletTextField.setText(servlet_url);
            dbserverurlTextField.setText(dbserver_url);
        }
        catch (FileNotFoundException ex) {
            System.err.println("Configuration file not found.");
            Logger.getLogger(WadsConfigDialog.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch(IOException ex) {
            System.err.println("Error occur when system try to save configurations.");
            Logger.getLogger(WadsConfigDialog.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void saveConfig() {
        String server = webserverTextField.getText();
        String servlet = servletTextField.getText();
        String dbserver = dbserverurlTextField.getText();

        if((server_url.compareTo(server)!=0)
                || (servlet_url.compareTo(servlet)!=0 )
                || (dbserver_url.compareTo(dbserver)!=0)) {
            configProps.setProperty(WADTools.SERVER_NAME_KEYNAME, server);
            configProps.setProperty(WADTools.ACTION_NAME_KEYNAME, servlet);
            configProps.setProperty(WADTools.DBSERVER_NAME_KEYNAME, dbserver);

            try {
                configProps.store(new FileOutputStream(configFile), "WADS' Configure.");
                System.out.println("Data have been changed.");
            }
            catch(IOException iox) {
                System.err.println("Can't save configurations.");
                iox.printStackTrace();
            }
        }
    }

    private Properties configProps = new Properties();
    private String server_url = "";
    private String servlet_url = "";
    private String dbserver_url = "";
    private File configFile = new File(WadsConfigDialog.CONFIG_FILENAME);
    private int dbType = 0; //default=0="", 1=localhost, 2=embedded, 3=internet
    public static final String CONFIG_FILENAME = "res/sys/config.prop";
    public static final String WEB_SERVER_URL_KEY = "serverURL";
    public static final String SERVLET_ACTION_URL_KEY = "servletURL";
    public static final String CURRENT_DB_TYPE_KEY = "currentDB"; // value can be >> localhost, embedded, internet
    public static final String REMEMBER_PASSWORD_KEY = "rememberPassword"; // value can be >> yes, no
    public static final String LOCAL_DB_URL_KEY = "localURL";
    public static final String LOCAL_DB_USERNAME_KEY = "localUsername";
    public static final String LOCAL_DB_PASSWORD_KEY = "localPassword";
    public static final String EMBEDDED_DB_URL_KEY = "embeddedURL";
    public static final String EMBEDDED_DB_USERNAME_KEY = "embeddedUsername";
    public static final String EMBEDDED_DB_PASSWORD_KEY = "embeddedPassword";
    public static final String INTERNET_DB_URL_KEY = "internetURL";
    public static final String INTERNET_DB_USERNAME_KEY = "internetUsername";
    public static final String INTERNET_DB_PASSWORD_KEY = "internetPassword";

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton applyButton;
    private javax.swing.JButton cancelButton;
    private javax.swing.ButtonGroup connectiontypeButtonGroup;
    private javax.swing.JLabel connectiontypeLabel;
    private javax.swing.JPasswordField dbpwPasswordField;
    private javax.swing.JPanel dbserverPanel;
    private javax.swing.JLabel dbserverpwLabel;
    private javax.swing.JTextField dbserverurlTextField;
    private javax.swing.JLabel dburlLabel;
    private javax.swing.JLabel dbusernameLabel;
    private javax.swing.JTextField dbusernameTextField;
    private javax.swing.JRadioButton embeddedRadioButton;
    private javax.swing.JRadioButton internetRadioButton;
    private javax.swing.JRadioButton localhostRadioButton;
    private javax.swing.JButton okButton;
    private javax.swing.JCheckBox rememberpwCheckbox;
    private javax.swing.JLabel serveltLabel;
    private javax.swing.JCheckBox servletCheckBox;
    private javax.swing.JTextField servletTextField;
    private javax.swing.JPanel servletactionPanel;
    private javax.swing.JButton testconnectButton;
    private javax.swing.JCheckBox webserverCheckBox;
    private javax.swing.JLabel webserverLabel;
    private javax.swing.JPanel webserverPanel;
    private javax.swing.JTextField webserverTextField;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the configProps
     */
    public Properties getConfigProps() {
        return configProps;
    }

    /**
     * @param configProps the configProps to set
     */
    public void setConfigProps(Properties configProps) {
        this.configProps = configProps;
    }

}
